package com.sdhs.costcontrol.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.sdhs.common.annotation.Log;
import com.sdhs.common.core.controller.BaseController;
import com.sdhs.common.core.domain.AjaxResult;
import com.sdhs.common.enums.BusinessType;
import com.sdhs.costcontrol.domain.GcControlConfirmationPurchaseList;
import com.sdhs.costcontrol.service.IGcControlConfirmationPurchaseListService;
import com.sdhs.common.utils.poi.ExcelUtil;
import com.sdhs.common.core.page.TableDataInfo;

/**
 * 成本控制--采购确认-明细Controller
 *
 * @author andong
 * @date 2025-03-17
 */
@RestController
@RequestMapping("/costcontrol/confirmationList")
public class GcControlConfirmationPurchaseListController extends BaseController
{
    @Autowired
    private IGcControlConfirmationPurchaseListService gcControlConfirmationPurchaseListService;

    /**
     * 查询成本控制--采购确认-明细列表
     */
    @PreAuthorize("@ss.hasPermi('costcontrol:list:list')")
    @GetMapping("/list")
    public TableDataInfo list(GcControlConfirmationPurchaseList gcControlConfirmationPurchaseList)
    {
        startPage();
        List<GcControlConfirmationPurchaseList> list = gcControlConfirmationPurchaseListService.selectGcControlConfirmationPurchaseListList(gcControlConfirmationPurchaseList);
        return getDataTable(list);
    }

    /**
     * 导出成本控制--采购确认-明细列表
     */
    @PreAuthorize("@ss.hasPermi('costcontrol:list:export')")
    @Log(title = "成本控制--采购确认-明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GcControlConfirmationPurchaseList gcControlConfirmationPurchaseList)
    {
        List<GcControlConfirmationPurchaseList> list = gcControlConfirmationPurchaseListService.selectGcControlConfirmationPurchaseListList(gcControlConfirmationPurchaseList);
        ExcelUtil<GcControlConfirmationPurchaseList> util = new ExcelUtil<GcControlConfirmationPurchaseList>(GcControlConfirmationPurchaseList.class);
        util.exportExcel(response, list, "成本控制--采购确认-明细数据");
    }

    /**
     * 获取成本控制--采购确认-明细详细信息
     */
    @PreAuthorize("@ss.hasPermi('costcontrol:list:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(gcControlConfirmationPurchaseListService.selectGcControlConfirmationPurchaseListById(id));
    }

    /**
     * 新增成本控制--采购确认-明细
     */
    @PreAuthorize("@ss.hasPermi('costcontrol:list:add')")
    @Log(title = "成本控制--采购确认-明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GcControlConfirmationPurchaseList gcControlConfirmationPurchaseList)
    {
        return toAjax(gcControlConfirmationPurchaseListService.insertGcControlConfirmationPurchaseList(gcControlConfirmationPurchaseList));
    }

    /**
     * 修改成本控制--采购确认-明细
     */
    @PreAuthorize("@ss.hasPermi('costcontrol:list:edit')")
    @Log(title = "成本控制--采购确认-明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GcControlConfirmationPurchaseList gcControlConfirmationPurchaseList)
    {
        return toAjax(gcControlConfirmationPurchaseListService.updateGcControlConfirmationPurchaseList(gcControlConfirmationPurchaseList));
    }

    /**
     * 删除成本控制--采购确认-明细
     */
    @PreAuthorize("@ss.hasPermi('costcontrol:list:remove')")
    @Log(title = "成本控制--采购确认-明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(gcControlConfirmationPurchaseListService.deleteGcControlConfirmationPurchaseListByIds(ids));
    }
}
